package com.chinasolf.tip;

import com.chinasolf.constant.MqConst;
import com.chinasolf.yygh.rabbit.RabbitService;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
@EnableScheduling
public class ScheduleTask {
    @Autowired
    private RabbitService rabbitService;
//    @Scheduled(cron = "0 0 20 * * ?")
    @Scheduled(cron = "0/10 * * * * ?")
    public void task1(){
        System.out.println(new Date().toLocaleString());
        //在每天晚上八点，查询第二天数据
        //在每天晚上八点，获取第二天日期
        DateTime dateTime = new DateTime().plusDays(1);
        String dateString = dateTime.toString("yyyy-MM-dd");
        //mq消息
        rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK,
                MqConst.ROUTING_TASK_8, dateString);


    }
}
